package com.spring.aop.base;

/**
 * @author liangd
 * date 2020-11-16 12:58
 * code
 */
public class MathCalculatorLoggingImpl implements MathCalculator {
    /**
     * 思路？在每个方法执行前后加上打印语句
     * 问题：
     * 1、代码混乱，代码重复太多，影响核心代码
     * 2、代码分散，修改某一条打印语句需要修改很多地方，不好维护
     */
    @Override
    public int add(int i, int j) {
        System.out.println("The method add begins with["+i+","+j+"]");
        int result = i+j;
        System.out.println("The method add ends with "+result);
        return result;
    }

    @Override
    public int sub(int i, int j) {
        System.out.println("The method sub begins with["+i+","+j+"]");
        int result = i-j;
        System.out.println("The method sub ends with "+result);
        return result;
    }

    @Override
    public int mul(int i, int j) {
        System.out.println("The method mul begins with["+i+","+j+"]");
        int result = i*j;
        System.out.println("The method mul ends with "+result);
        return result;
    }

    @Override
    public int div(int i, int j) {
        System.out.println("The method div begins with["+i+","+j+"]");
        int result=i/j;
        System.out.println("The method div ends with "+result);
        return result;
    }
}
